<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head th:replace="_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客管理</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/me.css">
</head>
<body>
<div class="m-container-small m-padded-tb-massive" style="max-width: 30em !important;">
    <div class="ui container">
        <div class="ui middle aligned center aligned grid">
            <div class="column">
                <h2 class="ui teal image header">
                    <div class="content">
                        注册
                    </div>
                </h2>
                <!--表单提交-->
                <form class="ui large form" onsubmit="return validate()" method="post" action="/registerCompelete" th:action="@{/registerCompelete}">
                    <div class="ui segment">
                        <div class="field">
                            <div class="ui left input">
                                <input type="text" name="nickname" placeholder="昵称">
                            </div>
                        </div>
                        <div class="field">
                            <div class="ui left icon input">
                                <i class="user icon"></i>
                                <input type="text" name="username" placeholder="用户名">
                            </div>
                        </div>
                        <div class="field">
                            <div class="ui left icon input">
                                <i class="lock icon"></i>
                                <input id="password" type="password" name="password" placeholder="密码">
                            </div>
                        </div>
                        <div class="field">
                            <div class="ui left icon input">
                                <i class="lock icon"></i>
                                <input id="againpassword" type="password" placeholder="再次输入">
                            </div>
                        </div>
                        <div class="field">
                            <div class="ui left icon input">
                                <i class="envelope open icon"></i>
                                <input type="text" name="email" placeholder="邮箱">
                            </div>
                        </div>
                        <button class="ui fluid large teal submit button">注 册</button>
                    </div>

                    <div class="ui error mini message"></div>
                    <div class="ui mini negative message" th:unless="${#strings.isEmpty(message)}" th:text="${message}">
                        用户名和密码错误
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!--/*/<th:block th:replace="_fragments :: script">/*/-->
<script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
<!--/*/</th:block>/*/-->
<script>
    function validate() {
        var n1 = document.getElementById("password");
        var n2 = document.getElementById("againpassword");
        if (n1.value != "" && n2.value != "") {
            if (n1.value == n2.value) {
                return true;
            }
        }
        alert("两次密码输入不同,请重新输入!");
        return false;
    };

    $('.ui.form').form({
        fields: {
            nickname: {
              identifier: 'nickname',
              rules: [{
                  type: 'empty',
                  prompt: '错误；请输入昵称'
              }]
            },
            username: {
                identifier: 'username',
                rules: [{
                    type: 'empty',
                    prompt: '错误：请输入用户名'
                }]
            },
            password: {
                identifier: 'password',
                rules: [{
                    type: 'empty',
                    prompt: '错误：请输入密码'
                }]
            },
            email: {
                identifier: 'email',
                rules: [{
                    type: 'empty',
                    prompt: '错误：请输入邮箱'
                }]
            }
        }
    });
</script>
</body>
</html>